<%-- 
    Document   : register_process
    Created on : 18-Jul-2013, 00:13:41
    Author     : MrMAD
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <jsp:useBean id="newCustomer" class="mybean.Customer"/>
        <jsp:setProperty name="newCustomer" property="*"/>
        <%
            String DoB = "";
            DoB += request.getParameter("day") + "/";
            DoB += request.getParameter("month") + "/";
            DoB += request.getParameter("year") + "/";
            out.println(DoB);
            
            if (!newCustomer.validEmail()) {
                session.setAttribute("validEmail", "false");
                String referer = request.getHeader("Referer");
                // handle empty referer.....
                response.sendRedirect(referer);
            }
            newCustomer.setDoB(DoB);            
            boolean register = newCustomer.register();
            if (register) {
                session.setAttribute("register", "OK");
                response.sendRedirect("http://localhost:8080/FinalProject/account.jsp");
            }
        %>
    </body>
</html>
